package lab02.test06;

public class Triangle {
    private double A;
    private double B;
    private double C;
    Boolean myTriangle;
    private double perimeter;
    private double area;

    Triangle(){}
    Triangle(double A,
             double B,double C,
             Boolean myTriangle,double perimeter,
             double area){
        this.A = A;
        this.B = B;
        this.C = C;
        this.myTriangle = myTriangle;
        this.perimeter = perimeter;
        this.area = area;
    }
    //使用set,get获取数据

    //面积的算法
    public void setArea(double area) {
        this.area = area;
    }

    public double getArea(double A,double B,double C) {
        double semit = (A+B+C)/2;
        double temp = (semit*(semit-A)*
                (semit-B)*(semit-C));
        area = Math.sqrt(temp);
        return area;
    }
    //周长的算法
    public void setPerimeter(double perimeter) {
        this.perimeter = perimeter;
    }

    public double getPerimeter(double A,double B,double C) {
        perimeter = A+B+C;
        return perimeter;
    }

    public double getA() {
        return A;
    }

    public void setA(double a) {
        A = a;
    }

    public double getB() {
        return B;
    }

    public void setB(double b) {
        B = b;
    }

    public double getC() {
        return C;
    }

    public void setC(double c) {
        C = c;
    }

    public void setMyTriangle(Boolean myTriangle) {
        this.myTriangle = myTriangle;
    }

    public Boolean getMyTriangle(double A,double B,double C) {
        if(A+B>C&&A+C>B&&C+B>A){
            myTriangle = true;
        }else{
            System.out.println("数据不能构成三角形");
        }
        return myTriangle;
    }
}
